package com.hlw.springboot.mapper;

import com.hlw.springboot.entity.SysRole;
import com.hlw.springboot.entity.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface SysUserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(SysUser record);

    int insertSelective(SysUser record);

    SysUser selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(SysUser record);

    int updateByPrimaryKey(SysUser record);

    @Select("  select * from sys_user where username = #{username}")
    SysUser findByName(@Param("username")String username);

    //layui前台可根据条件进行查询
    List<SysUser> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    int count(@Param("params") Map<String, Object> params);

    @Select(" select count(*) from sys_user where username = #{username}")
    int checkUserName(String username);

    @Update(" update sys_user set status =#{status}  where id = #{userId}")
    int updateStatus(int userId,byte status);


    Integer findRoleIdByUId(@Param("uid") int uid);

    @Select("select count(*) from sys_user_role where uid = #{uid} ")
    Integer selectCountByUId(@Param("uid") int uid);

    @Update("update sys_user_role rid set rid = ${rid} where uid = #{uid} ")
    Integer updateRoleByUId(@Param("uid") int uid,@Param("rid") int rid);

    @Insert("insert sys_user_role (uid,rid) value(#{uid},#{rid})  ")
    Integer insertRoleByUId(@Param("uid") int uid,@Param("rid") int rid);

}